<template>
    <!-- 
    <b-modal ref="my-modal" hide-footer title="Using Component Methods">
     <div class="d-block text-center">
       <h3>Hello From My Modal!</h3>
     </div>
     <b-button class="mt-3" variant="outline-danger" block @click="hideModal">Close Me</b-button>
     <b-button class="mt-2" variant="outline-warning" block @click="toggleModal">Toggle Me</b-button>
   </b-modal> 
    -->
    <!--
        body-class="modalStyle" 表示样式
        size="lg" 表示模态窗口大小 xl,lg,sm,full
        hide-footer 表示隐藏底部按钮
        hide-header 表示隐藏头部内容
        no-close-on-backdrop 表示鼠标点击背景不可关闭
        hide-header-close 表示隐藏头部关闭按钮
        centered 居中
        ok-title=“确定” 
        cancel-title=取消
        @ok="handleOk" 
        @cancel="handleCancel"
        scrollable 滚动条
        hide-backdrop 隐藏背景
        wrapClassName="ant-modal-cust-warp" 
        style="top:5%;height: 85%;overflow-y: hidden" 样式
    -->
    <b-modal ref="my-modal" size="lg" title="部门详情" scrollable hide-footer no-close-on-backdrop centered>
        <div class="d-block text-center">
            <!--begin::div-->
            <div class="m-form m-form--fit m-form--label-align-left m-form--group-seperator-dashed" method="post">
                <div class="m-portlet__body">
                    <div class="form-group m-form__group row">
                        <label class="col-md-2 col-form-label">上级部门</label>
                        <div class="col-md-3">
                            <input class="form-control" type="hidden" v-model="departInfoForm.id" placeholder="请输入">
                            <input class="form-control" type="hidden" maxlength="32"  v-model="departInfoForm.parentId"  placeholder="请选择部门父ID">
                            <input class="form-control" type="text" maxlength="32" value="无" v-model="departInfoForm.parentName" readonly="readonly">
                        </div>
                    </div>

                    <div class="form-group m-form__group row">
                        <label class="col-md-2 col-form-label">部门名称</label>
                        <div class="col-md-3">
                            <input class="form-control" type="text" maxlength="50"  v-model="departInfoForm.name" placeholder="请输入">
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-md-2 col-form-label">编&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码</label>
                        <div class="col-md-3">
                            <input class="form-control" type="text" maxlength="20" v-model="departInfoForm.code" placeholder="请输入">
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-md-2 col-form-label">联系电话</label>
                        <div class="col-md-3">
                            <input class="form-control" type="text" maxlength="12" v-model="departInfoForm.connectTelNo" placeholder="请输入">
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-md-2 col-form-label">移动电话</label>
                        <div class="col-md-3">
                            <input class="form-control" type="text" maxlength="20" v-model="departInfoForm.mobileTelNo" placeholder="请输入">
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-md-2 col-form-label">传&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;真</label>
                        <div class="col-md-3">
                            <input class="form-control" type="text" maxlength="50" v-model="departInfoForm.faxes" placeholder="请输入">
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-md-2 col-form-label" >描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述</label>
                        <div class="col-md-6">
                            <textarea class="form-control" maxlength="200" v-model="departInfoForm.remark" placeholder="请输入" ></textarea>
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-md-2 col-form-label">成立时间</label>
                        <div class="col-md-2">
                            <el-date-picker
                                align="left"
                                v-model="departInfoForm.setUpTime" 
                                style="width:150px"
                                type="date"
                                placeholder="请选择日期"
                                value-format="yyyy-MM-dd" format="yyyy-MM-dd"
                                :picker-options="pickerOptions">
                            </el-date-picker>                            
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-md-2 col-form-label" >部门性质</label>
                        <div class="col-md-4">
                            <input class="form-control" type="text" maxlength="200" v-model="departInfoForm.type" placeholder="请输入" >
                        </div>
                    </div>
                </div>
                <div class="m-portlet__foot m-portlet__no-border m-portlet__foot--fit">
                    <div class="m-form__actions m-form__actions--solid">
                        <div class="form-group m-form__group row">
                            <div class="col m--align-left">
                            </div>
                            <div class="col m--align-right">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--end::div-->
        </div>
        <template slot="modal-footer">
           
        </template>
    </b-modal>        
</template>
<script>
import apiUtil from "@/core/util/apiUtil.js"; 
import { handleNotify,handleAlert,handleConfirm,showWating,closeWating,deepClone} from "@/core/util/jehcUtil.js";
export default {
    data(){
        return {            
            pickerOptions: {
                disabledDate(time) {
                    return time.getTime() > Date.now();
                },
                shortcuts: [{
                    text: '今天',
                    onClick(picker) {
                        picker.$emit('pick', new Date());
                    }
                }, 
                {
                    text: '昨天',
                    onClick(picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24);
                        picker.$emit('pick', date);
                    }
                }, 
                {
                    text: '一周前',
                    onClick(picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                        picker.$emit('pick', date);
                    }
                }]
        },
        departInfoForm:{
            id: "",
            name: "",
            parentId:"0",
            parentName:"无",
            code:"",
            connectTelNo:"",
            mobileTelNo:"",
            faxes:"",
            remark:"",
            setUpTime:"",
            type:"",
        }
      }
    },
    components: {
    },
    watch: {
    },
    mounted() {        
    },
    methods: {
     showModal(id) {
       this.restForm();
       this.getDepartInfoDetail(id);
       this.$refs['my-modal'].show();
     },
     hideModal() {
       this.$refs['my-modal'].hide()
     },
     toggleModal() {
       // 当模态已隐藏时，我们传递要返回焦点的按钮的ID
       this.$refs['my-modal'].toggle('#toggle-btn')
     },
     restForm(){
        //重置
        Object.assign(this.$data.departInfoForm, this.$options.data().departInfoForm);
     },
     getDepartInfoDetail(id){
        apiUtil.get(process.env.VUE_APP_SYS_API+"/xtDepartinfo/get/"+id).then(({ data }) => {
            if(!data.data.parentName){
                data.data.parentName = "无"
            }
            this.departInfoForm = data.data;
           
            this.departInfoFormOld = deepClone(data.data);
        });
     },
   }
}
</script>

<style>
</style>